package com.itheima.homework15;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

public class Test10 {
    public static void main(String[] args) throws Exception {
        ServerSocket ss=new ServerSocket(10080);
        while (true){
            Socket socket = ss.accept();
                //回应服务器端
            BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            //获得网络的文件
            BufferedInputStream bis=new BufferedInputStream(socket.getInputStream());
            //写到本地
            String name= UUID.randomUUID().toString().replaceAll("-","");
            BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("javaSEday15\\"+name+".png"));
            int b;
            while ((b=bis.read())!=-1){
                bos.write(b);
            }


            bw.write("上传成功");
            bw.newLine();
            bw.flush();
            bos.close();
          //  ss.close();
        }



    }
}
